import axios from 'axios'
import { MessageBox, Message } from 'element-ui'

const instance=axios.create({
  baseURL:"http://localhost:8080",
  timeout:5000
});
//请求拦截器
instance.interceptors.request.use(function (config){
  return config;
},function (error){
  return Promise.reject(error);
});
//响应拦截器
instance.interceptors.response.use(function (response){
if(response.status===200){
  return Promise.resolve(response.data)
}else{
  console.log("错误》》请求错误");
  return Promise.reject({code:0,msg:"服务请求错误"})
}
},function (error){
  return Promise.reject(error)
})

export  default {
  post(url,data){
    return instance.post(url,data)
  },


  get(url,params){
    return instance.get(url,params)
  }
}
